package com.lwj.controller.administration;

import com.lwj.dto.administration.DepartmentDto;
import com.lwj.dto.administration.DepartmentListDto;
import com.lwj.entity.RestEntity;
import com.lwj.service.administration.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(tags ="部门接口")
@RestController()
@RequestMapping("/api/department")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;

    @ApiOperation(value = "部门树")
    @GetMapping("/tree")
    public RestEntity tree(@RequestParam(value = "departmentId",required = false) String departmentId,@RequestParam(value = "excludeDisable",defaultValue = "false")boolean excludeDisable){
        return RestEntity.success(departmentService.departmentTree(departmentId,excludeDisable));
    }
    @ApiOperation(value = "部门树")
    @PostMapping("/list")
    public RestEntity list(@RequestBody DepartmentListDto dto){
        return RestEntity.success(departmentService.listDepartment(dto));
    }

    @ApiOperation(value = "保存")
    @PostMapping("/save")
    public RestEntity save(@RequestBody DepartmentDto dto){
        return RestEntity.success(departmentService.saveDepartment(dto));
    }
}
